home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / gle / dviljx.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-29  |  1.4 KB  |  57 lines

  1. /* this is for a   Laserjet series II printer, which I think doesn't
  2. like the compressed data format */
  3.  
  4. #define XSIZECM 18        /* at 120 DPI  */
  5. #define YSIZECM 24        /* at 72 DPI */
  6. #define NXBITS 1064
  7. #define NYBITS 1424
  8.  
  9. #include "bitmap.h"
  10. dvitype(void)
  11. {
  12.     printf("Deskjet/Laserjet");
  13. }
  14. int ljsendline(char *s, int nc, int y);
  15. bitmap_print(void)
  16. {
  17.     int x,y;
  18.     static unsigned char out_buff[NXBITS+30];
  19.     unsigned char swapbit[256];
  20.     unsigned char swapnib[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
  21.     unsigned char *o,c;
  22.     int nc,i,n1,n2;
  23.  
  24.     printf("Writing out bitmap\n");
  25.     for (i=0;i<256;i++) {
  26.         n1 = i & 0xf;
  27.         n2 = (i >> 4) & 0xf;
  28.         swapbit[i] = swapnib[n2] | (swapnib[n1] << 4);
  29.     }
  30.     pprintf("%cE",27);     /* reset  */
  31.     pprintf("\x1b*t150R");    /* set resoulution 150 dpi */
  32.     for (y=(nybits-1); y>=0; y--) {
  33.       o = &out_buff[0];
  34.       for (x=0; x<(nxbits/8) ; x++) {
  35.         c = bitmap[y][x];
  36.         nc = 0;
  37. /*        for (;x<(nxbits/8-1) && bitmap[y][x+1]==c && nc<250; x++) nc++;
  38.         *o++ = nc;
  39. */
  40.         *o++ = swapbit[c];
  41.       }
  42.       ljsendline(out_buff,o-out_buff,y);
  43.     }
  44.     pprintf("\x0c"); /* form feed, reset origin */
  45. }
  46. ljsendline(char *s, int nc,int y)
  47. {
  48.     pprintf("\x1b&a%.1fH",0.0); /* move x */
  49.     pprintf("\x1b&a%.1fV",((NYBITS-y)/150.0)*720.0); /* move y */
  50. /*     pprintf("\x1b*b1M");   compact,  not used as I think it doesn't work */
  51.     pprintf("\x1b*r1A");    /* start graphics at cur pos */
  52.     pprintf("\x1b*b%dW",nc);    /* send y bytes */
  53.     printmem(s,nc);
  54.     pprintf("\x1b*rB");        /* end grpahics */
  55. }
  56.  
  57.